package com.zc.custom;

import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

/**
 * 自定义转换配置文件的内容到类属性的类型,如此类转换中是将String字符串以逗号为分隔,将String字符串分隔为一个数组,然后
 * 配置到配置属性类对应的字段上
 * @ConfigurationPropertiesBinding 配置属性绑定,
 */
@ConfigurationPropertiesBinding
@Component
public class CustomConverter implements Converter<String, List<String>> {
    @Override
    public List<String> convert(String source) {

        return Arrays.asList(source.split(","));
    }
}
